package interfaz;

import gestoresPasajeros.GestorPasajeros;
import gestoresPasajeros.NomencladorDatosPersonales;
import gestoresPasajeros.NomencladorGeografico;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JFormattedTextField;
import javax.swing.text.MaskFormatter;
import java.awt.event.*;


public class AltaPasajero extends javax.swing.JFrame {

    //Declaracion de Variables//
    private int limite  = 30;         //limitar la cantidad de caracteres ingresados en los texfields
    private int limiteDoc = 8;
    private int limiteCalle = 20;
    private int limiteDepto = 4;
    private int limitePiso = 3;
    private int limiteCPyNum = 6;
    private int limiteTelefono = 10;
    private JButton boton_Cancelar=new JButton();
    private JButton boton_Siguiente=new JButton();
    private JComboBox <String> box_Localidad=new JComboBox<String>();
    private JComboBox <String> box_Nacionalidad=new JComboBox<String>();
    private JComboBox <String> box_Ocupacion=new JComboBox<String>();
    private JComboBox <String> box_Pais=new JComboBox<String>();
    private JComboBox <String> box_PosFrenteIVA=new JComboBox<String>();
    private JComboBox <String> box_Provincia=new JComboBox<String>();
    private JComboBox <String> box_tipoDoc =new JComboBox<String>();
    private ButtonGroup buttonGroup1 =new ButtonGroup();
    private ButtonGroup buttonGroup2=new ButtonGroup();
    private JPanel jPanel1=new JPanel();
    private JPanel jPanel5=new JPanel();
    private JPanel jPanel7=new JPanel();
    private JPanel jPanel8=new JPanel();
    private JSeparator jSeparator1=new JSeparator();
    private JSeparator jSeparator2=new JSeparator();
    private JSeparator jSeparator3=new JSeparator();
    private JSeparator jSeparator4=new JSeparator();
    private JSeparator jSeparator5=new JSeparator();
    private JSeparator jSeparator6=new JSeparator();
    private JLabel lbl_Apellido=new JLabel();
    private JLabel lbl_CP =new JLabel();
    private JLabel lbl_CUIT=new JLabel();
    private JLabel lbl_Calle=new JLabel();
    private JLabel lbl_Contacto=new JLabel();
    private JLabel lbl_DatosPersonales=new JLabel();
    private JLabel lbl_Depto=new JLabel();
    private JLabel lbl_Direccion=new JLabel();
    private JLabel lbl_Email=new JLabel();
    private JLabel lbl_Localidad=new JLabel();
    private JLabel lbl_Nacionalidad=new JLabel();
    private JLabel lbl_Nombre=new JLabel();
    private JLabel lbl_Ocupacion=new JLabel();
    private JLabel lbl_Otros=new JLabel();
    private JLabel lbl_Pais=new JLabel();
    private JLabel lbl_Piso=new JLabel();
    private JLabel lbl_PosFrenteIVA=new JLabel();
    private JLabel lbl_Provincia=new JLabel();
    private JLabel lbl_Telefono=new JLabel();
    private JLabel lbl_fechaNac=new JLabel();
    private JLabel lbl_nro=new JLabel();
    private JLabel lbl_nroDoc=new JLabel();
    private JLabel lbl_tipoDoc=new JLabel();
    private JTextField txt_Apellido=new JTextField();
    private JTextField txt_CP=new JTextField();
    /*private JTextField txt_CUIT=new JTextField();*/
    private JFormattedTextField txt_CUIT = new javax.swing.JFormattedTextField();
    private JTextField txt_Calle=new JTextField();
    private JTextField txt_Depto=new JTextField();
    private JTextField txt_Email=new JTextField();
    private JTextField txt_Nombre=new JTextField();
    private JTextField txt_Piso=new JTextField();
    private JTextField txt_Telefono=new JTextField();
    /*private JFormattedTextField txt_fechaNac=new JFormattedTextField();*/
    private JFormattedTextField txt_fechaNac= new javax.swing.JFormattedTextField();
    private JTextField txt_nro=new JTextField();
    private JTextField txt_nroDoc=new JTextField();
    
    
    //Consutructor de la interfaz
    public AltaPasajero() {
        initComponents();
        posicionarElementos();
        soloMayusculas();
        inicializarComboBox();
        setResizable(false);
        setVisible(true);
        
    }

  
    @SuppressWarnings("unchecked")
   //inicializar y setear componentes                          
    private void initComponents() {

       setDefaultCloseOperation(EXIT_ON_CLOSE);

        txt_CUIT.setText("     -                          -");
        txt_fechaNac.setText("DD/MM/AAAA");
        lbl_Apellido.setText("Apellido");
        lbl_Nombre.setText("Nombre");
        lbl_nroDoc.setText("Documento");
        lbl_tipoDoc.setText("Tipo");
        lbl_CUIT.setText("CUIT/CUIL");
        lbl_PosFrenteIVA.setText("Posicion frente al IVA");
        lbl_fechaNac.setText("Fecha de Nacimiento");
        lbl_Calle.setText("Calle");
        lbl_nro.setText("Nº");
        lbl_Depto.setText("Depto");
        lbl_Pais.setText("Pais");
        lbl_Provincia.setText("Provincia");
        lbl_Localidad.setText("Localidad");
        lbl_CP.setText("CP");
        lbl_Piso.setText("Piso");
        lbl_Direccion.setText("Direccion");
        lbl_Contacto.setText("Contacto");
        lbl_Telefono.setText("Telefono");
        lbl_Email.setText("Email");
        lbl_Otros.setText("Otros");
        boton_Siguiente.setText("Siguiente");
        boton_Cancelar.setText("Cancelar");
        lbl_DatosPersonales.setText("Datos Personales");
        lbl_Nacionalidad.setText("Nacionalidad");
        lbl_Ocupacion.setText("Ocupacion");
        
        /* ************COMIENZO PARA EL LÍMITE DE LOS TEXTFIELDS*********************** */
        txt_Apellido.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Apellido.getText().length()== limite){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Nombre.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Nombre.getText().length()== limite){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Email.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Email.getText().length()== limite){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_nroDoc.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_nroDoc.getText().length()== limiteDoc){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Depto.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Depto.getText().length()== limiteDepto){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Piso.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Piso.getText().length()== limitePiso){
                    getToolkit().beep();
                    e.consume();
                    
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Telefono.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Telefono.getText().length()== limiteTelefono){
                    getToolkit().beep();
                    e.consume();
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_Calle.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_Calle.getText().length()== limiteCalle){
                    getToolkit().beep();
                    e.consume();
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_nro.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_nro.getText().length()== limiteCPyNum){
                    getToolkit().beep();
                    e.consume();
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
        txt_CP.addKeyListener(new KeyListener(){
            public void keyTyped(KeyEvent e){
                if (txt_CP.getText().length()== limiteCPyNum){
                    getToolkit().beep();
                    e.consume();
                }
                }
            public void keyPressed(KeyEvent arg0) {}
            public void keyReleased(KeyEvent arg0){}
              });
        
         try {
            txt_CUIT.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##-########-#")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txt_CUIT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_CUITActionPerformed(evt);
            }
        });
        try {
            txt_fechaNac.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txt_fechaNac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_fechaNacActionPerformed(evt);
            }
        });
        //añadimos los action listener
            boton_Siguiente.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
            	
            	boton_SiguienteAccion(evt); }});
               
            box_Pais.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
            	
            	box_PaisAccion(evt); }});
            
              box_Provincia.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
            	
            	box_ProvinciaAccion(evt); }});
    }                       

   
    private void posicionarElementos(){
    //metodo que posiciona los componentes dentro del panel
                javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txt_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_Nombre))
                        .addGap(46, 46, 46)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_Apellido)
                            .addComponent(txt_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(box_tipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_tipoDoc))
                                .addGap(36, 36, 36)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_nroDoc)
                                    .addComponent(txt_nroDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(lbl_fechaNac)
                            .addComponent(txt_fechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(29, 29, 29)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(box_PosFrenteIVA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txt_CUIT, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_CUIT)
                            .addComponent(lbl_PosFrenteIVA))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_Nombre)
                    .addComponent(lbl_Apellido))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txt_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_Apellido, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_nroDoc)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_tipoDoc)
                        .addComponent(lbl_CUIT)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_nroDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(box_tipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_CUIT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_fechaNac)
                    .addComponent(lbl_PosFrenteIVA))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_fechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(box_PosFrenteIVA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
                javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(txt_Calle, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_nro)
                                    .addComponent(txt_nro, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txt_Depto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbl_Depto, javax.swing.GroupLayout.Alignment.TRAILING)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel5Layout.createSequentialGroup()
                                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(lbl_Pais)
                                            .addComponent(lbl_Calle))
                                        .addGap(95, 95, 95))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                        .addComponent(box_Pais, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_Provincia)
                                    .addComponent(box_Provincia, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbl_Localidad)
                                    .addComponent(box_Localidad, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_Piso)
                            .addComponent(txt_Piso, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_CP)
                            .addComponent(txt_CP, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(125, 125, 125))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_Calle)
                    .addComponent(lbl_nro)
                    .addComponent(lbl_Depto)
                    .addComponent(lbl_Piso))
                .addGap(6, 6, 6)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_Calle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txt_nro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_Depto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txt_Piso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_Localidad)
                            .addComponent(lbl_Provincia))
                        .addComponent(lbl_Pais))
                    .addComponent(lbl_CP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(box_Pais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(box_Provincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(box_Localidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_CP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
                javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txt_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_Telefono))
                .addGap(36, 36, 36)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_Email)
                    .addComponent(txt_Email, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(lbl_Otros)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator5)
                .addGap(2, 2, 2))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_Telefono)
                    .addComponent(lbl_Email))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txt_Email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(lbl_Otros, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        
        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_Ocupacion)
                    .addComponent(box_Ocupacion, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(74, 74, 74)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_Nacionalidad)
                    .addComponent(box_Nacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_Nacionalidad)
                    .addComponent(lbl_Ocupacion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(box_Ocupacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(box_Nacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(68, 68, 68)
                .addComponent(boton_Cancelar)
                .addGap(210, 210, 210)
                .addComponent(boton_Siguiente)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator6)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(lbl_DatosPersonales)
                        .addGap(79, 79, 79)
                        .addComponent(jSeparator1))
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbl_Direccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(lbl_Contacto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator4))
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_DatosPersonales))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_Direccion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbl_Contacto)
                    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(boton_Siguiente)
                    .addComponent(boton_Cancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }

    //metodo encargado de que la visualizacion de los campos de entrada sea siempre en MAYUS
    private void soloMayusculas(){
    
//primero obtenemos le FocusManager (que a su vez es el KeyEventDispatcher)
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();

//y enseguida registramos nuestro dispatcher
manager.addKeyEventDispatcher(new KeyEventDispatcher(){
        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {

                //como dije, solo las notificaciones del tipo "typed" son las que actualizan los componentes
                if(e.getID() == KeyEvent.KEY_TYPED){

                        //como vamos a convertir todo a mayúsculas, entonces solo checamos si los caracteres son
                        //minusculas
                        if(e.getKeyChar() >= 'a' && e.getKeyChar() <= 'z'){
                                //si lo son, entonces lo reemplazamos por su respectivo en mayúscula en el mismo evento
                                // (esto se logra por que en java todas las variables son pasadas por referencia)
                                e.setKeyChar((char)(((int)e.getKeyChar()) - 32));
                        }
                }
                //ya que por default la propiedad name en los jtextfield es nula, debemos hacer la comprobación que se me estaba pasando.
            if(e.getSource() instanceof JComponent
                && ((JComponent)e.getSource()).getName() != null
                && ((JComponent)e.getSource()).getName().startsWith("ignore_upper_case")){
        return false;
}
                //y listo, regresamos siempre falso para que las demas notificaciones continuen, si regresamos true
                // significa que el dispatcher consumio el evento
                return false;
        }

    
   
});}
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AltaPasajero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AltaPasajero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AltaPasajero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AltaPasajero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            new AltaPasajero().setVisible(true);
            }
            
        });
    }

        
    //Metodos inicializadores de comboBox//
    private void inicializarComboBox(){
       NomencladorDatosPersonales nomDP= NomencladorDatosPersonales.getInstance();
        
        
         for(String str: nomDP.getListadoOcupacion()){             
              box_Ocupacion.addItem(str);}
         for(String str: nomDP.getListadoPosicionesIVA()){             
              box_PosFrenteIVA.addItem(str);}
        for(String str: nomDP.getListadoTipoDni()){             
              box_tipoDoc.addItem(str);}
          for(String str: nomDP.getListadoNacionalidades()){             
              box_Nacionalidad.addItem(str);}
         
  
    
    NomencladorGeografico nomGeo= NomencladorGeografico.getInstance();
          
        for(String str: nomGeo.getListadoPais()){             
              box_Pais.addItem(str);}
        
         
          
  }
        
    //metodos de accion de botones
     private void boton_SiguienteAccion(ActionEvent evt)   {  
         GestorPasajeros gestor= GestorPasajeros.getInstance();
         String guiones_cuit = txt_CUIT.getText();
         String guiones_reemplazados= guiones_cuit.replace("-","");
         
         if(gestor.validarCampos(txt_Nombre.getText(),txt_Apellido.getText(),(String) guiones_reemplazados,txt_fechaNac.getText(),txt_Calle.getText(), txt_nro.getText(), txt_Depto.getText(), txt_Piso.getText(), txt_CP.getText(), txt_Email.getText(), txt_Telefono.getText(), (String) box_tipoDoc.getSelectedItem(),txt_nroDoc.getText())){
         
        
         if(gestor.altaPasajero(txt_Nombre.getText(), txt_Apellido.getText(),(String) box_tipoDoc.getSelectedItem(),txt_nroDoc.getText(),(String) guiones_reemplazados,txt_fechaNac.getText(), (String)box_PosFrenteIVA.getSelectedItem(),txt_Calle.getText(), txt_nro.getText(), txt_Depto.getText(), txt_Piso.getText(),(String) box_Pais.getSelectedItem(), (String)box_Provincia.getSelectedItem(), (String)box_Localidad.getSelectedItem(), txt_CP.getText(), txt_Email.getText(), txt_Telefono.getText(), (String)box_Ocupacion.getSelectedItem(),(String)box_Nacionalidad.getSelectedItem())==true){
         JOptionPane.showMessageDialog(null, "Se ha cargado correctamente","Exito",JOptionPane.OK_OPTION );
         this.dispose();
         GestionarPasajeros ges=new GestionarPasajeros();
         }
         }else{
         }
    }  
     private void box_PaisAccion(ActionEvent evt)   {
        box_Provincia.removeAllItems();
         NomencladorGeografico nomGeo= NomencladorGeografico.getInstance();
         String paisSeleccionado=(String) box_Pais.getSelectedItem();
          for(String str: nomGeo.getListadoProvinciaPorPais(paisSeleccionado)){             
              box_Provincia.addItem(str);}
     }
     
          private void box_ProvinciaAccion(ActionEvent evt)   {
         box_Localidad.removeAllItems();
         NomencladorGeografico nomGeo= NomencladorGeografico.getInstance();
         String provSeleccionado=(String) box_Provincia.getSelectedItem();
          for(String str: nomGeo.getListadoLocalidadPorProvincia(provSeleccionado)){             
              box_Localidad.addItem(str);}
     }
           private void txt_CUITActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
         }
           private void txt_fechaNacActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        }
}
        